<template>
  <el-form >
    <el-form-item label="昵称">
      <el-input v-model.trim="user.urName" />
    </el-form-item>
    <el-form-item label="用户名">
      <el-input v-model.trim="user.urUsername" />
    </el-form-item>
    <el-form-item label="性别">
        <br>
    <el-select  v-model="user.urSex">
      <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      >
      </el-option>
    </el-select>
    </el-form-item>
    <el-form-item label="邮箱">
      <el-input v-model.trim="user.urEmail" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">Update</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import {update} from '@/api/user'
export default {
  data() {
    return {
      options: [
        {
          value: 0,
          label: "男",
        },
        {
          value: 1,
          label: "女",
        },
      ],
    };
  },
  props: {
    user: {
      type: Object,
      default: () => {
        return {
          name: "",
          email: "",
        };
      },
    },
  },
  methods: {
    submit() {
      update(this.user).then(res=>{
          this.user=res.data.data
      })
      this.$message({
        message: "资料修改成功",
        type: "success",
        duration: 5 * 1000,
      });
    },
  },
};
</script>
